Skip to content

feat(backend): add validated environment config module#290

Open
anika00mangla wants to merge 12 commits into
Dev-Card:mainfrom
anika00mangla:main
Open

feat(backend): add validated environment config module#290
anika00mangla wants to merge 12 commits into
Dev-Card:mainfrom
anika00mangla:main

Conversation

@anika00mangla
Copy link
Copy Markdown

Summary

Adds a typed, schema-validated environment configuration module (apps/backend/src/config.ts)
that parses and validates all variables from .env.example at server startup. If any required
variable is missing, empty, contains an unfilled placeholder, or fails a security constraint,
the process exits immediately with a clear human-readable error before the server accepts any
requests. All direct process.env reads across the backend have been replaced with imports
from the new config module.

Closes #255


Type of Change

  • Bug fix
  • New feature
  • Refactor (no functional change)
  • UI / Design change
  • Tests only
  • Documentation
  • Infrastructure / DevOps
  • Security

What Changed

  • Added apps/backend/src/config.ts — validates all env vars at startup with a typed AppConfig interface; exits with a descriptive error on any misconfiguration
  • Added apps/backend/src/__tests__/config.test.ts — unit tests covering missing, empty, placeholder, and malformed values for every variable
  • Replaced all process.env reads in apps/backend/src/app.ts with config imports
  • Replaced all process.env reads in apps/backend/src/server.ts with config imports
  • Replaced all process.env reads in apps/backend/src/plugins/prisma.ts with config imports
  • Replaced all process.env reads in apps/backend/src/plugins/redis.ts with config imports
  • Replaced all process.env reads in apps/backend/src/utils/encryption.ts with config imports
  • Replaced all process.env reads in apps/backend/src/routes/auth.ts with config imports

Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Signed-off-by: Anika Mangla <anumangla122@gmail.com>
Signed-off-by: Anika Mangla <anumangla122@gmail.com>
@Harxhit Harxhit added the gssoc:approved Required label for every approved PR. Gives the base +50 points and enables contribution tracking. label May 23, 2026
@Prince2301p
Copy link
Copy Markdown

Hi,
I would like to work on resolving this issue. Please assign it to me. I’m a participant in GSSoC 2026 and would be happy to contribute.
Looking forward to collaborating with you.

Signed-off-by: Anika Mangla <anumangla122@gmail.com>
@anika00mangla
Copy link
Copy Markdown
Author

@sahilsultane pla merge the pr the issue has been resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved Required label for every approved PR. Gives the base +50 points and enables contribution tracking.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

backend: validate and enforce environment variable schema at application startup

3 participants